/**
 * Copyright 2015 Qiyi Inc. All rights reserved.
 * 
 * @file:   Carousel.Action.js
 * @author: karkarrotxu@qiyi.com
 * @date:   2016-05-30
 */
qui(
    function(require, exports, module) {
        Carousel.Action = (function(){
            var listGrid = null;
            var insertGrid = null;
            var libraryGrid = null;
            var ruleGrid = null;
            var automationRuleGrid = null;
            var listRun = function(){
                if (!listGrid) {
                    listGrid = new Carousel.Grid($.extend(true, {
                        $grid:$('#list'),
                        type: 0
                    }, {}));
                }
                listGrid.runDayList();
                console.log('Carousel grid runDayList');
            }
            var insertRun = function(){
                if (!insertGrid) {
                    insertGrid = new Carousel.Grid($.extend(true, {
                        $gridType1:$('#listAdd1'),
                        $gridType2:$('#listAdd2'),
                        type: 0
                    }, {}));
                }
                insertGrid.runInsertList();
                console.log('Carousel grid runInsertList');
            }

            var libraryRun =function (){
                if (!libraryGrid) {
                    libraryGrid = new Carousel.Grid($.extend(true, {
                        $grid:$('#list'),
                        type: 0
                    }, {}));
                }
                libraryGrid.runLibrary();
                console.log('Carousel grid runLibrary');
            }

//            var ruleRun =function (){
//                if (!ruleGrid) {
//                    ruleGrid = new Carousel.Grid($.extend(true, {
//                        $grid:$('#list'),
//                        type: 0,
//                        model:"rule"
//                    }, {}));
//                }
//                ruleGrid.runRule();
//                console.log('Carousel grid runRule');
//            }

            var automationRuleRun =function (){
                if (!automationRuleGrid) {
                    automationRuleGrid = new Carousel.AutomationRuleGrid($.extend(true, {
              //      automationRuleGrid = new Carousel.Grid($.extend(true, {
                        $grid:$('#ruleList'),
                        type: 0,
                        model:"automation_rule"
                    }, {}));
                }
                automationRuleGrid.runAutomationRule();
                console.log('Carousel grid runAutomationRule');
            }

            return {
                listRun:listRun,
                insertRun:insertRun,
                libraryRun:libraryRun,
             //   ruleRun:ruleRun,
                automationRuleRun:automationRuleRun
            }
        })();

    }
);